def is_valid_bracket_sequence(sequence):
    stack = []
    mapping = {')': '(', ']': '[', '}': '{', '>': '<'}
    for bracket in sequence:
        if bracket in mapping.values():
            stack.append(bracket)
        elif bracket in mapping.keys():
            if not stack or mapping[bracket] != stack.pop():
                return False
    return not stack

input_sequence = input()
if is_valid_bracket_sequence(input_sequence):
    print("True")
else:
    print("False")
